package inject;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Website {
    
     public static StringBuilder getWebsiteOutput(String url) {
        
        StringBuilder sb = new StringBuilder();
        
        try {

            URL downloadUrl = new URL(url);
            URLConnection connection = downloadUrl.openConnection();

            connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0");

            BufferedReader in = new BufferedReader(
                    new InputStreamReader(connection.getInputStream())
            );

            String output;


            while ((output = in.readLine()) != null) {

                sb.append(output).append("\n");

            }
            
            in.close();
        } catch(Exception e) {
            
            e.printStackTrace();
            
        }
            
        return sb;
    }
     
     
    public static String findAndReplaceUrl(String url, String replacement) {
        
        String output = url;

        return output.replace("[INJ]", replacement);
    }
    
}
